package com.example.asuper.check;

import android.app.Activity;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.TextView;

import com.example.asuper.check.Db.CheckDAL;
import com.example.asuper.check.Helper.ConvertHelper;
import com.example.asuper.check.Helper.SharePrefenceHelper;
import com.example.asuper.check.Model.CheckModel;

public class Detailinfo extends Activity {
    private TextView tv_show;
    private CheckDAL checkService;
    private String SpliteCode;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_detailinfo);
        tv_show = (TextView) findViewById(R.id.tv_detail_show);
        SpliteCode= SharePrefenceHelper.ReadSharedPreferences("splite_info","SPLITE",this);
        Intent intent = getIntent();
        String checkCode = intent.getStringExtra("code");
        try {
            checkService = new CheckDAL(this);
            CheckModel scanResult = checkService.getCheckModel(checkCode);
            String showResult = "[编号]：" + scanResult.getCheckCode() + "\r\n[状态]: " + ConvertHelper.getStateName(scanResult.getState()) + "\r\n";
            if (scanResult.getRemark() != null) {
                String[] names = scanResult.getCheckName().split(SpliteCode);
                String[] msgs = scanResult.getRemark().split(SpliteCode);
                for (int i = 0; i < msgs.length; i++) {
                    showResult += "[" + names[i] + "] : " + msgs[i] + "\r\n";
                }
            }
            tv_show.setText(showResult);
        } catch (Exception e) {

        }
    }
}
